/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package centralehotel.dao;

import centralehotel.dao.interfaces.AgenceDAOLocal;
import centralehotel.modele.Agence;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Mathieu
 */
@Stateless
public class AgenceDAO implements AgenceDAOLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Agence agence) {
        em.persist(agence);
    }

    public void edit(Agence agence) {
        em.merge(agence);
    }

    public void remove(Agence agence) {
        em.remove(em.merge(agence));
    }

    public Agence find(Object id) {
        return em.find(centralehotel.modele.Agence.class, id);
    }

    public List<Agence> findAll() {
        return em.createQuery("select object(o) from Agence as o").getResultList();
    }

}
